#include<iostream>
#include<queue>
using namespace std;
int vx[1300][130][65];
int addX[6]={1,-1,0,0,0,0};
int addY[6]={0,0,1,-1,0,0};
int addZ[6]={0,0,0,0,1,-1};
bool isvisited[1300][130][65];
int M,N,L,T;//M,N,L:Size,T:linjie
class Nodes{
public:
    int x;
    int y;
    int z;
};//The Coordinates
bool judge(int x,int y,int z){
    if(x<0||x>=M||y<0||y>=N||z<0||z>=L||isvisited[x][y][z]==true||vx[x][y][z]==false){
	return false;
    }else{
	return true;
    }
}
int bfs(int x,int y,int z){//broad-first search
    Nodes N;
    N.x=x;
    N.y=y;
    N.z=z;
    queue<Nodes> Queue;//create a queue
    Queue.push(N);
    int cnt=0;//mark the # of strokes!
    isvisited[x][y][z]=true;//visited!
    while(Queue.size()){//Isn't empty
	Nodes tmp=Queue.front();
	Queue.pop();//deque
	cnt++;
	for(int i=0;i<6;i++){
	    int tx=tmp.x+addX[i];
	    int ty=tmp.y+addY[i];
	    int tz=tmp.z+addZ[i];
	    if(judge(tx,ty,tz)){//There is a stroke on this point!
		isvisited[tx][ty][tz]=true;
		tmp.x=tx;
		tmp.y=ty;
		tmp.z=tz;
		Queue.push(tmp);
	    }
	}
    }
    if(cnt>=T){
	return cnt;
    }else{
	return 0;
    }
}
int main(){
    cin>>M>>N>>L>>T;
    for(int i=0;i<L;i++){
	for(int j=0;j<M;j++){
	    for(int k=0;k<N;k++){
		cin>>vx[j][k][i];
	    }
	}
    }
    int ans=0;
    for(int i=0;i<L;i++){
	for(int j=0;j<M;j++){
	    for(int k=0;k<N;k++){
		if(vx[j][k][i]==1&&isvisited[j][k][i]==false){
		    ans=ans+bfs(j,k,i);
		}
	    }
	}
    }
    cout<<ans<<endl;
}
